﻿@{
    Layout = null;
}

<!DOCTYPE html>

<html style="height: 100%;" >
<head>
    <meta name="viewport" content="width=device-width" />
    <title>用户列表</title>
    @Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/jqueryEasyui/js")
    @Styles.Render("~/jqueryEasyui/css")
    <script src="/Scripts/jQuery.Extensions.js"></script>

    <script language="javascript" type="text/javascript">

        $(function () {
            $('#UserList').datagrid({
                url: "/adminweb/user/getUserList",
                singleSelect: true,
                height: $("body").height()-10,
                onLoadSuccess: function () {
                    $('.easyui-linkbutton').linkbutton({height:20});
                },
                columns: [[
                    { title: "用户名", field: "Account", width: 150, halign: "center" },
                    { title: "管理员姓名", field: "UserName", width: 150, halign: "center" },
                    { title: "Email", field: "Email", width: 200, halign: "center" },
                    {
                        title: "状态", field: "IsDisabled", width: 70, align: "center",
                        formatter: function (value, row, index) {
                            if (value) {
                                return "开启";
                            } else {
                                return "禁用";
                            }
                        }
                    },
                    {
                        title: "创建时间", field: "CreateTime", width: 140, align: "center",
                        formatter: function (value, row, index) {
                            return sjn.toDate(value).format();
                        }
                    },
                    {
                        title: "操作", field: "tool", width: 200, align: "center",
                        formatter: function (value, row, index) {
                            var htm = '<a href="javascript:void(0);" class="easyui-linkbutton" onclick="EditAlter(\'' + row.UserID + '\')" data-options="iconCls:\'icon-edit\',plain:true">编辑</a>';
                            return htm;
                        }
                    }
                ]],
                view: detailview,
                detailFormatter: function (index, row) {
                    return '<div style="padding:2px"><table class="ddv"></table></div>';
                },
                onExpandRow: function (index, row) {
                    var ddv = $(this).datagrid('getRowDetail', index).find('table.ddv');
                    ddv.datagrid({
                        url: '/adminweb/user/getAdminRolesByAdminId/' + row.UserID,
                        title: "所拥有的角色",
                        fitColumns: true,
                        singleSelect: true,
                        rownumbers: true,
                        loadMsg: '',
                        height: 'auto',
                        columns: [[
                            { field: 'RoleName', title: '角色名称', width: 100 },
                            {
                                field: 'RoleIntro', title: '说明', width: 100,
                                formatter: function (value, row, index) {
                                    if (value == "null") {
                                        return "";
                                    } else {
                                        return value;
                                    }
                                }
                            }
                        ]],
                        onResize: function () {
                            $('#UserList').datagrid('fixDetailRowHeight', index);
                        },
                        onLoadSuccess: function () {
                            setTimeout(function () {
                                $('#UserList').datagrid('fixDetailRowHeight', index);
                            }, 0);
                        }
                    });
                    $('#UserList').datagrid('fixDetailRowHeight', index);
                }
            });  // end datagrid


        });

        //“编辑” 按钮事件
        var EditAlter = function (uid) {
            var data = $('#UserList').datagrid("getData");
            var editData;
            $(data.rows).each(function (i, item) {
                if (item.UserID == uid) {
                    editData = item;
                }
            });
            //获取要编辑的数据
            $.ifdata("editData", editData);
            $("#edit").dialog({
                title: '管理员信息修改',
                width: 550,
                height: 380,
                closed: false,
                cache: false,
                content: '<iframe scrolling="no" frameborder="0" src="/adminweb/user/edit" style="width:100%;height:98%;"></iframe>',
                modal: true
            })
        };

    </script>
</head>
<body style="height: 100%">
    <div>
        <table id="UserList">
        </table>
    </div>
    <div id="edit"></div>
    <div id="drole"></div>
</body>
</html>
